package com.ruoyi.web.controller.system;

import java.util.List;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysFonds;
import com.ruoyi.system.service.ISysFondsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 全宗信息Controller
 *
 * @author ruoyi
 * @date 2022-02-10
 */
@RestController
@RequestMapping("/system/fonds")
public class SysFondsController extends BaseController
{
    @Autowired
    private ISysFondsService sysFondsService;

    /**
     * 查询全宗信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:fonds:list')")
    @ApiOperation("查询全宗信息列表")
    @GetMapping("/list")
    public TableDataInfo list(SysFonds sysFonds)
    {
        startPage();
        List<SysFonds> list = sysFondsService.selectSysFondsList(sysFonds);
        return getDataTable(list);
    }
    /**
     * 导出全宗信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:fonds:export')")
    @Log(title = "全宗信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysFonds sysFonds)
    {
        List<SysFonds> list = sysFondsService.selectSysFondsList(sysFonds);
        ExcelUtil<SysFonds> util = new ExcelUtil<SysFonds>(SysFonds.class);
        return util.exportExcel(list, "fonds");
    }

    /**
     * 获取全宗信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:fonds:query')")
    @ApiOperation("获取全宗信息详细信息")
    @ApiImplicitParam(name = "recNo", value = "全宗信息编号", required = true, dataType = "String", paramType = "传全宗信息编号")
    @GetMapping("/selectbyid")
    public AjaxResult getInfo(SysFonds sysFonds)
    {
        return AjaxResult.success(sysFondsService.selectSysFondsById(sysFonds.getRecNo()));
    }

    /**
     * 新增全宗信息
     */
    @PreAuthorize("@ss.hasPermi('system:fonds:add')")
    @Log(title = "全宗信息", businessType = BusinessType.INSERT)
    @ApiOperation("新增全宗信息")
    @ApiImplicitParam(name = "sysFonds", value = "全宗信息对象", required = true, dataType = "SysFonds", paramType = "传全宗信息对象")
    @PostMapping
    public AjaxResult add(@RequestBody SysFonds sysFonds)
    {
        return toAjax(sysFondsService.insertSysFonds(sysFonds));
    }

    /**
     * 修改全宗信息
     */
    @PreAuthorize("@ss.hasPermi('system:fonds:edit')")
    @Log(title = "全宗信息", businessType = BusinessType.UPDATE)
    @ApiOperation("修改全宗信息")
    @ApiImplicitParam(name = "sysFonds", value = "全宗信息对象", required = true, dataType = "SysFonds", paramType = "传全宗信息对象")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody SysFonds sysFonds)
    {
        return toAjax(sysFondsService.updateSysFonds(sysFonds));
    }

    /**
     * 批量删除全宗信息
     */
    @PreAuthorize("@ss.hasPermi('system:fonds:remove')")
    @Log(title = "全宗信息", businessType = BusinessType.DELETE)
    @ApiOperation("批量删除全宗信息")
    @ApiImplicitParam(name = "recNos", value = "全宗信息编号数组", required = true, dataType = "String[]", paramType = "全宗信息编号数组")
    @GetMapping("/{recNos}")
    public AjaxResult remove(@PathVariable String[] recNos)
    {
        return toAjax(sysFondsService.deleteSysFondsByIds(recNos));
    }

    /**
     * 删除全宗信息
     */
    @PreAuthorize("@ss.hasPermi('system:fonds:remove')")
    @Log(title = "全宗信息", businessType = BusinessType.DELETE)
    @ApiOperation("删除全宗信息")
    @ApiImplicitParam(name = "sysFonds", value = "全宗信息对象", required = true, dataType = "SysFonds", paramType = "全宗信息对象")
    @GetMapping("/removeid")
    public AjaxResult removeid(SysFonds sysFonds)
    {
        return toAjax(sysFondsService.deleteSysFondsById(sysFonds));
    }
}
